{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>活动列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
                <div  class="col-sm-2" style="width: 100px">
                    <div class="input-group" >  
                        <a href="{:url('add_activity')}"><button class="btn btn-primary" type="button">添加活动</button></a> 
                    </div>
                </div>                                                                    
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th>ID</th>
                                <th width="15%">标题</th>
                                <th width="5%">海报图片</th>
                                <th>开始时间</th>
                                <th>结束时间</th>
                                <th width="15%">活动说明</th>
                                <th width="5%">状态</th>
                                <th width="15%">创建时间</th>
                                <th width="20%">操作</th>
                            </tr>
                        </thead>
                        <tbody id="article_list">
                            {foreach name="lists" item="vo"}
                                <tr class="long-td">
                                    <td>{$vo.id}</td>
                                    <td>{$vo.title}</td>
                                    <td><img src="{$vo.poster_pic}" style="height: 30px" onerror="this.src='/static/admin/images/no_img.jpg'"/></td>
                                    <td>{$vo.start_time|date="Y-m-d",###}</td>          
                                    <td>{$vo.end_time|date="Y-m-d",###}</td>
                                    <td>{$vo.remark}</td>           
                                    <td>
                                        {if condition="$vo['status'] == 1"}
                                            <a href="javascript:;" onclick="activity_state({$vo.id},-1);">
                                                <div id="zt{$vo.id}"><span class="label label-info">有效</span></div>
                                            </a>
                                        {else/}    
                                            <a href="javascript:;" onclick="activity_state({$vo.id},1);">
                                                <div id="zt{$vo.id}"><span class="label label-danger">关闭</span></div>
                                            </a>
                                        {/if}   
                                    </td>
                                    <td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
                                    <td>
                                        <a href="{:url('edit_activity',['id'=>$vo.id])}" class="btn btn-primary btn-xs">
                                            <i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp;
                                        <a href="javascript:;" onclick="del_activity({$vo.id})" class="btn btn-danger btn-xs">
                                            <i class="fa fa-trash-o"></i> 删除</a>   
                                    </td>
                                </tr>
                            {/foreach}
                        </tbody>
                    </table>
                </div>
                <!-- 分页 -->
                <div id="Pages">  {$page} </div>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}


<script type="text/javascript">

function del_activity(id){
    layer.confirm('确认删除此数据?', {icon: 3, title:'提示'}, function(index){
        //do something
        $.getJSON("{:url('del_activity')}", {'id' : id}, function(res){
            if(res.code == 1){
                layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
                    window.location.href="{:url('activity/index')}";
                });               
            }else{
                layer.msg(res.msg,{icon:0,time:1500,shade: 0.1});
            }
        });

        layer.close(index);
    })

}

function activity_state(val,status){
    $.post('{:url("activity_state")}',
    {id:val,status:status},
    function(res){
       layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
            window.location.href="{:url('activity/index')}";
        });
    });
    return false;
}


</script>
</body>
</html>